function buildRequests(formData: {
  stock_symbol: string;
  analysis_date: number;
  analysts: string[];
  research_depth: number;
  market_type: string;
}): {
  stock_symbol: string;
  analysis_date: number;
  analysts: string[];
  research_depth: number;
  market_type: string;
}[] {
  const { stock_symbol } = formData;
  const requests = stock_symbol
    .split(",")
    .filter((item) => {
      const trimmedItem = item.trim();
      return trimmedItem !== ""; // 过滤空值或仅含空白字符的项
    })
    .map((item) => {
      const trimmedItem = item.trim();
      const newitem = { ...formData }; // 创建formData的副本以避免引用问题
      newitem.stock_symbol = trimmedItem;
      return newitem;
    });

  if (requests.length === 0) {
    throw new Error("股票代码不能为空");
  }

  return requests;
}

export { buildRequests };
